e[Single]
#ScriptVersion[2]
#Title[Sʏ2]

script_enemy_main{
	
	let optionx = [0, 0, 0, 0, 0, 0];
	let optiony = [0, 0, 0, 0, 0, 0];
	
	@Initialize{
		//f[^
		InitializeData();
		InitializeAction();
		
		//Ctݒ
		SetLife( 3500 );
		//ʒuݒ
		Warp( CenterX, MinY + 90, 40 );
		//_[W[gݒ
		SetDamageRate( 100, 100 );
		//蔻ݒ
		SetCollisionEx( 32, 16, false, 60 );
		//Gl~[}[J[
		SetEnemyMarker( true );
		
		//C^XNJn
		TMain();
	}
	
	@MainLoop{
		//yield[v
		yield;
	}
	
	@DrawLoop{
		//{X摜`
		SetGraphicScale( xscale, yscale );
		DrawBoss( imgBoss );
	}
	
	@Finalize{
		//ŏI
		FinalizeData();
	}
	
	/**
	 * C^XN
	 */
	task TMain(){
		//60F(1b)҂
		FWait( 60 );
		
		//Ԑݒ
		SetTimer( 38 );
		
		//U
		alternative( difficult )
			case( "Easy" ){
				Atack_Easy();
			}
			case( "Normal" ){
				Atack_Normal();
			}
			case( "Panic" ){
				Atack_Panic();
			}
	}
	
	/**
	 * Easy UC^XN
	 */
	task Atack_Easy(){
	}
	
	/**
	 * Normal UC^XN
	 */
	task Atack_Normal(){
	}
	
	/**
	 * Panic UC^XN
	 */
	task Atack_Panic(){
		Atack();
	}
	
	/**
	 * U^XN
	 */
	task Atack(){
		ascent( i in 0..6 ){
			OptionDraw( i );
		}
		
		loop{
			Atack1();
			Atack2();
		}
	}
	
	function Atack1(){
		let angle = rand( 0, 360 );
		
		ascent( i in 0..6 ){
			OptionMove( i, GetGapX( 0, 92, angle + i * 60 ), GetGapY( 0, 92, angle + i * 60 ), 30 );
		}
		FWait( 50 );
		
		ascent( i in 0..240 ){
			ascent( j in 0..6 ){
				if( i % 20 < 8 ){
					let x = GetX() + optionx[j];
					let y = GetY() + optiony[j];
					let sangle = angle + j * 60 + i * 1.2 * (j % 2 * 2 - 1);
					let graph = 0;
					if( j % 2 == 0 ){
						graph = US_BALL_S_RED;
					}else{
						graph = US_BALL_S_BLUE;
					}
					ascent( k in 0..4 ){
						CreateShot01( x, y, 2.6 + i * 0.014, sangle + k * 90, graph, 0 );
					}
				}
			}
			yield;
		}
	}
	
	function Atack2(){
		ascent( i in 0..6 ){
			OptionMove( i, (i - 2.5) * 66, rand( -10, 10 ), 30 );
		}
		FWait( 50 );
		
		ascent( i in 0..3 ){
			ascent( j in 0..19 ){
				ascent( k in 0..7 ){
					CreateShot01( GetX(), GetY(), 2.8 + k * 1 / 7 + i * 0.5, GetAngleToPlayer() + ( j - 9 ) * 2.4, US_BALL_M_PURPLE, 0 );
				}
			}
			ascent( j in 0..20 ){
				ascent( k in 0..6 ){
					let x = GetX() + optionx[k];
					let y = GetY() + optiony[k];
					let angle = GetGapAngle( x, y, GetPlayerX(), GetPlayerY() );
					ascent( l in 0..3 ){
						CreateShot01( x, y, 4.2 + j * 5 / 20 + i * 0.3, angle + ( l - 1 ) * 30, US_RICE_M_BLUE, 0 );
					}
				}
				FWait( 3 );
			}
			FWait( 20 );
		}
		
		ascent( j in 0..51 ){
			ascent( k in 0..10 ){
				CreateShot01( GetX(), GetY(), 1.2 + k * 0.8 / 7, GetAngleToPlayer() + ( j - 25 ) * 2.4, US_BALL_M_PURPLE, 60 );
			}
		}
		ascent( j in 0..30 ){
			ascent( k in 0..6 ){
				let x = GetX() + optionx[k];
				let y = GetY() + optiony[k];
				let angle = GetGapAngle( x, y, GetPlayerX(), GetPlayerY() );
				ascent( l in 0..3 ){
					CreateShot01( x, y, 4.2 + j * 5 / 20, angle + ( l - 1 ) * 30, US_RICE_M_BLUE, 0 );
				}
			}
			FWait( 3 );
		}
		
		FWait( 120 );
	}
	
	/**
	 * IvV̕`
	 */
	task OptionDraw( i ){
		loop{
			GrowEffect( GetX() + optionx[i], GetY() + optiony[i], PURPLE01, 24, 23 );
			yield;
		}
	}
	
	/**
	 * IvV̈ړ
	 */
	task OptionMove( i, x, y, frame ){
		let mx = ( x - optionx[i] ) / frame;
		let my = ( y - optiony[i] ) / frame;
		
		loop( frame ){
			optionx[i] = optionx[i] + mx;
			optiony[i] = optiony[i] + my;
			yield;
		}
	}
	
	//XNvg̃CN[h
	#include_function ".\initialize.txt"
	#include_function ".\..\..\..\Library\lib_effect.txt"
}